package org.stayfool.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.stayfool.client.event.EventManager;
import org.stayfool.client.event.MqttEvent;

/**
 * Created by stayfool on 2017/2/16.
 */
public class EventHandler extends ChannelInboundHandlerAdapter {

    @Override
    @SuppressWarnings("unckecked")
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if (evt instanceof MqttEvent) {
            MqttEvent event = (MqttEvent) evt;
            EventManager.notify(event.getKey(), event.getMessage());
        }
    }
}
